﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using Ylh.DBUtility;
using Ylh.IDAL;
using Ylh.Model;
using System.Data;
using System.Data.SqlClient;

namespace Ylh.SQLServerDAL
{
    public class CompetenceDAL : ICompetence
    {
        /// <summary>
        /// 根据编号获取权限信息
        /// </summary>
        /// <param name="ConStr"></param>
        /// <param name="ID">编号</param>
        /// <param name="IsParent">指定编号是否是父节点编号</param>
        /// <returns></returns>
        public DataTable GetCompetenceByID(string ConStr, decimal ID, bool? IsParent)
        {
            string sql = @"SELECT * FROM TbCompetence where 1=1";

            if (IsParent != null)
            {
                if (Convert.ToBoolean(IsParent))sql += " and  ParentID=" + ID;
                else sql += " and  CompetenceID=" + ID;
            }

            return SqlHelper.ExcuteQuery(ConStr, sql, CommandType.Text);
        }

        /// <summary>
        /// 系统管理员专用
        /// </summary>
        /// <param name="ConStr"></param>
        /// <returns></returns>
        public DataTable GetCompetenceByCode(string ConStr)
        {
            string sql = @"select * FROM TbCompetence where  CompetenceCode='SysSetManger'";
            return SqlHelper.ExcuteQuery(ConStr, sql, CommandType.Text);
        }


    }
}
